#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
int a[N];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int q;
  cin >> q;
  sort(a, a + n);
  while (q--) {
    int l, r, x;
    cin >> l >> r >> x;
    cout << upper_bound(a + l, a + r + 1, x) - lower_bound(a + l, a + r + 1, x)
         << endl;
  }
}
